<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="common/layout">

<head>
    <title>编辑菜单类别</title>
    <script th:inline="javascript">
        $(function(){
            setTimeout(function(){
                $("#categoryForm").ajaxForm({
                            callback: function(data) {
                                if (data.valid) {
                                    self.location.href = data.url || '/';
                                } else {
                                    alert(data.errorMsg);
                                }
                            },
                            validate: function(data) {
                                var category_name = $("#category_name").val();

                                if(category_name.length==0){
                                    alert("类别名不能为空");
                                    return false;
                                }
                                if(category_name.length>10){
                                    alert("类别名最大长度为10");
                                    return false;
                                }
                                return true;
                            }
                        }
                )
            },200);
        });

        function edit_cancel() {
            self.location.href = '/admin/category';
        };
    </script>
</head>
<body>

<section layout:fragment="top_menu" style="text-align: left;padding-left: 20px">
    <span style="font-size: 20px">修改菜品类别</span>
</section>


<section layout:fragment="content">

    <div class="main" style="margin: 5px">
        <form id="categoryForm" class="form" th:action="@{/admin/category/{id}(id=${category.id})}" th:object="${category}" th:method="PUT">
            <table>
                <tbody>
                <tr>
                    <td style="text-align: right">
                        类别
                    </td>
                    <td>
                        <input id="category_name"  th:field="*{name}" name="name"  type="text" >
                    </td>
                </tr>

                <tr>
                    <td colspan="2" style="text-align: center">
                        <input type="submit" class=" new_button_yellow input_submit" value="保存">
                        <input type="button"  onclick="javascript:edit_cancel()"  class="new_button_yellow" value="取消">
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>

</section>


</body>



</html>